<?php 
	require 'UnpaidManager.php';
	if($_SESSION['properlogin'] != 1){ header("Location:error.html"); }
	if($_GET['in'] == 0){
		UnpaidManager::getData($_GET['order']);
	}
	$nrows = $_SESSION['numrows'];
	$items = 10;	
	$numIndex = (int)($nrows / $items);
	if($nrows % $items > 0)
		$numIndex++;
	$_SESSION['curPage'] = $_GET['cp']
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script type="text/javascript">
</script>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Unpaid Residents</title>
<script type="text/javascript" src="validateInformation.js" ></script>
<script src="sorttable.js"></script>

<link href="style.css" rel="stylesheet" type="text/css" />
<style type="text/css">
</style>
</head>

<body>
<table width="100%" border="0" cellpadding="1">
 
  <tr>
    <td>&nbsp;</td>
    <td class="subBanner">&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td class="subBanner"><strong> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;List of Unpaid Residents</strong></td>
    <td>&nbsp;</td>
  </tr>
  <tr>	
    <td>&nbsp;</td>	
    <td><form id="form1" name="form1" method="post" action="" >
		<table width="100%" border="0" cellpadding="1">
			<tr>
				<td width="32%" class="confirm" id="search" style="text-align:left"><a href="unpaidView.php?order=NAMELAST&cp=0&in=0">NAME</a></td>
				<td width="19%" class="confirm" id="search" style="text-align:left"><a href="unpaidView.php?order=STUDENTNO&cp=0&in=0">STUDENT NUMBER</a></td>
				<td width="19%" class="confirm" id="search" style="text-align:left"><a href="unpaidView.php?order=ROOMNO&cp=0&in=0">ROOM NUMBER</a></td>
				<td width="30%" class="confirm" id="search" style="text-align:left"><a href="unpaidView.php?order=PERIODCOVERED&cp=0&in=0">NO. OF MONTHS UNPAID</a></td>
			</tr>
			<?php
			for($i = 0; $i < $nrows; $i++) {
				if(($i >= $_SESSION['curPage'] * $items) && ($i < ($_SESSION['curPage'] + 1) * $items))
					echo "<tr>\n";
				else
					echo "<tr style='display:none'>";
				echo "<td style='text-align:left'>" . $_SESSION['results']['NAMELAST'][$i] . ", " . $_SESSION['results']['NAMEFIRST'][$i] . " " . $_SESSION['results']['NAMEMIDDLE'][$i] . "</td>\n";
				echo "<td style='text-align:left'>" . $_SESSION['results']['STUDENTNO'][$i] . "</td>\n";
				echo "<td style='text-align:left'>" . $_SESSION['results']['ROOMNO'][$i] . "</td>\n";
				$unpaid=5-intval( $_SESSION['results']['PERIODCOVERED'][$i]);
				echo "<td style='text-align:left'>" . $unpaid . "</td>\n";
				echo "</tr>\n";
			}
			?>
        </table>
    </form></td>
    <td>&nbsp;</td>
  </tr>	
  <tr>
    <td>&nbsp;</td>
    <td>
	<?php
	for($i = 0; $i < $numIndex; $i++){
		if($i == $_SESSION['curPage'])
			echo "&nbsp;". ($i + 1);
		else
			echo "&nbsp;<a href ='unpaidView.php?cp=" . $i . "&in=1'>" . ($i + 1) . "</a>";
	}
	
	?>
	</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
</table>
</body>
</html>